package org.example.ui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.concurrent.SubmissionPublisher;

public class StartFrame extends JFrame implements ActionListener {

    private JButton start;
    
    public StartFrame()
    {
        initJFrame();

        initView();

        this.setVisible(true);
    }

    private void initView() {
        JLabel promptLabel = new JLabel();
        promptLabel.setBounds(50,80,400,150);
        promptLabel.setFont(new Font("微软雅黑",Font.PLAIN,28));
        promptLabel.setText("Java 机考");
        promptLabel.setHorizontalAlignment(JLabel.CENTER);
        promptLabel.setVerticalAlignment(JLabel.CENTER);
        this.getContentPane().add(promptLabel);

        JLabel warning = new JLabel();
        warning.setBounds(50,240,400,240);
        warning.setText(
                "<html>1. 总共有10题，均为不定选项题，每题10分<br><br>"+
                "2.每道题限时10秒中作答<br><br>"+
                "3.所选选项和答案一致时得分，其余情况不得分</html>");
        this.getContentPane().add(warning);

        start = new JButton("开始考试");
        start.setBounds(200,500,100,40);
        start.addActionListener(this);
        this.getContentPane().add(start);
    }

    private void initJFrame() {
        this.setSize(500,750);
        this.setLayout(null);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setAlwaysOnTop(true);
        this.setLocationRelativeTo(null);
        this.setTitle("Java机考 开始页");
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getSource() == start)
        {
            this.dispose();
            new AnswerFrame();
        }
    }
}
